home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_oth / xlisp / xlisp.mem < prev   
Text File  |  1987-06-25  |  55KB  |  1,326 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.                  XLISP: An Experimental Object Oriented Language
  7.  
  8.                                    Version 1.5
  9.  
  10.                                   May 27, 1985
  11.  
  12.  
  13.                                         by
  14.                                 David Michael Betz
  15.                                 114 Davenport Ave.
  16.                               Manchester, NH  03103
  17.  
  18.                               (603) 625-4691 (home)
  19.  
  20.                     Copyright (c) 1985, by David Michael Betz
  21.                                All Rights Reserved
  22.             Permission is granted for unrestricted non-commercial use
  23.  
  24.  
  25.       XLISP: An Experimental Object Oriented Language                 Page 2
  26.       TABLE OF CONTENTS
  27.  
  28.  
  29.                                          CONTENTS
  30.  
  31.               1       INTRODUCTION . . . . . . . . . . . . . . . . . . . . 3
  32.               2       A NOTE FROM THE AUTHOR . . . . . . . . . . . . . . . 4
  33.               3       XLISP COMMAND LOOP   . . . . . . . . . . . . . . . . 5
  34.               4       BREAK COMMAND LOOP   . . . . . . . . . . . . . . . . 6
  35.               5       DATA TYPES . . . . . . . . . . . . . . . . . . . . . 7
  36.               6       THE EVALUATOR  . . . . . . . . . . . . . . . . . . . 8
  37.               7       LEXICAL CONVENTIONS  . . . . . . . . . . . . . . . . 9
  38.               8       OBJECTS  . . . . . . . . . . . . . . . . . . . . .  10
  39.               8.1       THE 'Object' CLASS . . . . . . . . . . . . . . .  11
  40.               8.2       THE 'Class' CLASS  . . . . . . . . . . . . . . .  12
  41.               9       SYMBOLS  . . . . . . . . . . . . . . . . . . . . .  13
  42.               10      FUNCTION DEFINITIONS . . . . . . . . . . . . . . .  14
  43.               10.1      EVALUATION FUNCTIONS . . . . . . . . . . . . . .  14
  44.               10.2      SYMBOL FUNCTIONS . . . . . . . . . . . . . . . .  15
  45.               10.3      PROPERTY LIST FUNCTIONS  . . . . . . . . . . . .  17
  46.               10.4      LIST FUNCTIONS . . . . . . . . . . . . . . . . .  18
  47.               10.5      DESTRUCTIVE LIST FUNCTIONS . . . . . . . . . . .  21
  48.               10.6      PREDICATE FUNCTIONS  . . . . . . . . . . . . . .  22
  49.               10.7      CONTROL FUNCTIONS  . . . . . . . . . . . . . . .  24
  50.               10.8      LOOPING FUNCTIONS  . . . . . . . . . . . . . . .  25
  51.               10.9      THE PROGRAM FEATURE  . . . . . . . . . . . . . .  26
  52.               10.10     DEBUGGING AND ERROR HANDLING . . . . . . . . . .  27
  53.               10.11     ARITHMETIC FUNCTIONS . . . . . . . . . . . . . .  28
  54.               10.12     BITWISE LOGICAL FUNCTIONS  . . . . . . . . . . .  30
  55.               10.13     RELATIONAL FUNCTIONS . . . . . . . . . . . . . .  31
  56.               10.14     STRING FUNCTIONS . . . . . . . . . . . . . . . .  32
  57.               10.15     INPUT/OUTPUT FUNCTIONS . . . . . . . . . . . . .  33
  58.               10.16     FILE I/O FUNCTIONS . . . . . . . . . . . . . . .  34
  59.               10.17     SYSTEM FUNCTIONS . . . . . . . . . . . . . . . .  35
  60.  
  61.  
  62.       XLISP: An Experimental Object Oriented Language                 Page 3
  63.       INTRODUCTION
  64.  
  65.  
  66.       1  INTRODUCTION
  67.  
  68.       XLISP is an experimental programming language combining  some  of  the
  69.       features of LISP with an object oriented extension capability.  It was
  70.       implemented to allow experimentation with object oriented  programming
  71.       on  small  computers.   There are currently implementations running on
  72.       the the VAX under VAX/VMS and  Berkeley  VAX/UNIX,  on  the  8088/8086
  73.       under  CP/M-86  and  MS-DOS,  on  the  68000 under CP/M-68K and on the
  74.       Macintosh.  It is completely written in the programming  language  'C'
  75.       and  is  easily  extended  with  user  written  built-in functions and
  76.       classes.   It  is  available  in  source  form  free  of   charge   to
  77.       non-commercial users.
  78.  
  79.       Many traditional LISP functions are built into  XLISP.   In  addition,
  80.       XLISP   defines  the  objects  'Object'  and  'Class'  as  primitives.
  81.       'Object' is the only class that has no superclass  and  hence  is  the
  82.       root  of  the class heirarchy tree.  'Class' is the class of which all
  83.       classes are instances (it is the only object that is  an  instance  of
  84.       itself).
  85.  
  86.       This document is a  brief  description  of  XLISP.   It  assumes  some
  87.       knowledge   of   LISP  and  some  understanding  of  the  concepts  of
  88.       object-oriented programming.
  89.  
  90.       A recommended text for learning LISP programming is the book "LISP" by
  91.       Winston  and  Horn and published by Addison Wesley.  The first edition
  92.       of this book is based on MacLisp and the second edition  is  based  on
  93.       Common  Lisp.   Future  versions  of  XLISP  will  continue to migrate
  94.       towards compatibility with Common Lisp.
  95.  
  96.  
  97.       XLISP: An Experimental Object Oriented Language                 Page 4
  98.       A NOTE FROM THE AUTHOR
  99.  
  100.  
  101.       2  A NOTE FROM THE AUTHOR
  102.  
  103.       If you have any problems with XLISP, feel free to contact me for  help
  104.       or  advice.   Please  remember that since XLISP is available in source
  105.       form in a high level language, many users have  been  making  versions
  106.       available  on  a variety of machines.  If you call to report a problem
  107.       with a specific version, I may not be able to help you if that version
  108.       runs  on  a  machine  to  which  I don't have access.  Please have the
  109.       version number of the version that you are running readily  accessible
  110.       before calling me.
  111.  
  112.       If you find a bug in XLISP, first try to fix the  bug  yourself  using
  113.       the  source  code  provided.  If you are successful in fixing the bug,
  114.       send the bug report along with the fix  to  me.   If  you  don't  have
  115.       access to a C compiler or are unable to fix a bug, please send the bug
  116.       report to me and I'll try to fix it.
  117.  
  118.       Any suggestions for improvements  will  be  welcomed.   Feel  free  to
  119.       extend the language in whatever way suits your needs.  However, PLEASE
  120.       DO NOT RELEASE ENHANCED VERSIONS WITHOUT CHECKING WITH ME  FIRST!!   I
  121.       would  like  to be the clearing house for new features added to XLISP.
  122.       If you want to add features for your own personal use, go ahead.  But,
  123.       if  you  want  to  distribute your enhanced version, contact me first.
  124.       Please remember that the goal of XLISP is to  provide  a  language  to
  125.       learn  and  experiment  with  LISP  and object-oriented programming on
  126.       small computers.  I don't want it to  get  so  big  that  it  requires
  127.       megabytes of memory to run.
  128.  
  129.  
  130.       XLISP: An Experimental Object Oriented Language                 Page 5
  131.       XLISP COMMAND LOOP
  132.  
  133.  
  134.       3  XLISP COMMAND LOOP
  135.  
  136.       When XLISP is started, it first tries  to  load  "init.lsp"  from  the
  137.       default directory.  It then loads any files named as parameters on the
  138.       command line (after appending ".lsp" to their names).  It then  issues
  139.       the following prompt:
  140.  
  141.       >
  142.  
  143.       This indicates that XLISP is waiting for an expression  to  be  typed.
  144.       When  an  incomplete expression has been typed (one where the left and
  145.       right parens don't match) XLISP changes its prompt to:
  146.  
  147.       n>
  148.  
  149.       where n is an integer indicating how many levels of left parens remain
  150.       unclosed.
  151.  
  152.       When a  complete  expression  has  been  entered,  XLISP  attempts  to
  153.       evaluate  that  expression.  If the expression evaluates successfully,
  154.       XLISP prints the result of the evaluation  and  then  returns  to  the
  155.       initial prompt waiting for another expression to be typed.
  156.  
  157.       Input can be aborted at any time by typing the CONTROL-G key  (it  may
  158.       be necessary to follow CONTROL-G by RETURN).
  159.  
  160.  
  161.       XLISP: An Experimental Object Oriented Language                 Page 6
  162.       BREAK COMMAND LOOP
  163.  
  164.  
  165.       4  BREAK COMMAND LOOP
  166.  
  167.       When XLISP encounters an error  while  evaluating  an  expression,  it
  168.       attempts to handle the error in the following way:
  169.  
  170.       If the symbol '*breakenable*' is true, the  message  corresponding  to
  171.       the  error  is  printed.   If the error is correctable, the correction
  172.       message is printed.  If the symbol '*tracenable*'  is  true,  a  trace
  173.       back  is  printed.  The number of entries printed depends on the value
  174.       of the symbol '*tracelimit*'.  If this  symbol  is  set  to  something
  175.       other  than  a  number, the entire trace back stack is printed.  XLISP
  176.       then enters a read/eval/print loop to allow the user  to  examine  the
  177.       state  of  the  interpreter  in  the  context of the error.  This loop
  178.       differs from the normal top-leval read/eval/print loop in that if  the
  179.       user   invokes the function 'continue'  XLISP  will  continue  from  a
  180.       correctable error.  If the user invokes the function 'quit' XLISP will
  181.       abort  the  break  loop  and return to the top level or the next lower
  182.       numbered break loop.  When in a break loop, XLISP prefixes  the  break
  183.       level to the normal prompt.
  184.  
  185.       If the symbol '*breakenable*' is nil, XLISP looks  for  a  surrounding
  186.       errset  function.   If  one  is found, XLISP examines the value of the
  187.       print flag.  If this flag is true, the error message is  printed.   In
  188.       any case, XLISP causes the errset function call to return nil.
  189.  
  190.       If there is no surrounding errset function,  XLISP  prints  the  error
  191.       message and returns to the top level.
  192.  
  193.  
  194.       XLISP: An Experimental Object Oriented Language                 Page 7
  195.       DATA TYPES
  196.  
  197.  
  198.       5  DATA TYPES
  199.  
  200.       There are several different data types available to XLISP programmers.
  201.  
  202.  
  203.             o  lists
  204.  
  205.             o  symbols
  206.  
  207.             o  strings
  208.  
  209.             o  integers
  210.  
  211.             o  floats
  212.  
  213.             o  objects
  214.  
  215.             o  file pointers
  216.  
  217.             o  subrs (built-in functions)
  218.  
  219.             o  fsubrs (special forms)
  220.  
  221.       Another data type is the stream.  A stream is a list  node  whose  car
  222.       points  to  the head of a list of integers and whose cdr points to the
  223.       last list node of the list.  An empty stream is a list node whose  car
  224.       and  cdr  are  nil.   Each  of  the  integers in the list represents a
  225.       character in the stream.  When a character is read from a stream,  the
  226.       first integer from the head of the list is removed and returned.  When
  227.       a character is written to  a  stream,  the  integer  representing  the
  228.       character  code  of  the character is appended to the end of the list.
  229.       When a  function  indicates  that  it  takes  an  input  source  as  a
  230.       parameter,  this  parameter  can  either be an input file pointer or a
  231.       stream.  Similarly, when a function indicates that it takes an  output
  232.       sink  as  a  parameter,  this  parameter  can either be an output file
  233.       pointer or a stream.
  234.  
  235.  
  236.       XLISP: An Experimental Object Oriented Language                 Page 8
  237.       THE EVALUATOR
  238.  
  239.  
  240.       6  THE EVALUATOR
  241.  
  242.       The process of evaluation in XLISP:
  243.  
  244.             o  Integers, floats, strings, file pointers, subrs,  fsubrs  and
  245.                objects evaluate to themselves
  246.  
  247.             o  Symbols evaluate to the value associated with  their  current
  248.                binding
  249.  
  250.             o  Lists are evaluated by evaluating the first  element  of  the
  251.                list and then taking one of the following actions:
  252.  
  253.                 o  If  it  is  a  subr,  the  remaining  list  elements  are
  254.                    evaluated  and  the  subr  is called with these evaluated
  255.                    expressions as arguments.
  256.  
  257.                 o  If it  is  an  fsubr,  the  fsubr  is  called  using  the
  258.                    remaining list elements as arguments (unevaluated)
  259.  
  260.                 o  If it is a list:
  261.  
  262.                    1.  If the list is a function closure (a list  whose  car
  263.                        is   a   lambda   expression  and  whose  cdr  is  an
  264.                        environment list), the car of the list is used as the
  265.                        function  to  be  applied  and the cdr is used as the
  266.                        environment  to  be  extended  with   the   parameter
  267.                        bindings.
  268.  
  269.                    2.  If the list  is  a  lambda  expression,  the  current
  270.                        environment is used for the function application.
  271.  
  272.                    3.  In either of the above two cases, the remaining  list
  273.                        elements  are evaluated and the resulting expressions
  274.                        are bound to  the  formal  arguments  of  the  lambda
  275.                        expression.   The  body  of  the function is executed
  276.                        within this new binding environment.
  277.  
  278.  
  279.                 o  If it is a list and the car of the list is  'macro',  the
  280.                    remaining list elements are bound to the formal arguments
  281.                    of the macro expression.  The body  of  the  function  is
  282.                    executed within this new binding environment.  The result
  283.                    of this evaluation is  considered  the  macro  expansion.
  284.                    This  result  is  then evaluated in place of the original
  285.                    expression.
  286.  
  287.                 o  If it is an object, the second list element is  evaluated
  288.                    and  used  as  a message selector.  The message formed by
  289.                    combining the selector with the values of  the  remaining
  290.                    list elements is sent to the object.
  291.  
  292.  
  293.  
  294.  
  295.       XLISP: An Experimental Object Oriented Language                 Page 9
  296.       LEXICAL CONVENTIONS
  297.  
  298.  
  299.       7  LEXICAL CONVENTIONS
  300.  
  301.       The following conventions are followed when entering XLISP programs:
  302.  
  303.       Comments in XLISP code begin with a semi-colon character and  continue
  304.       to the end of the line.
  305.  
  306.       Symbol names in  XLISP  can  consist  of  any  sequence  of  non-blank
  307.       printable characters except the following:
  308.  
  309.               ( ) ' ` , " ;
  310.  
  311.       Uppercase and lowercase characters are not distinguished within symbol
  312.       names.  All lowercase characters are mapped to uppercase on input.
  313.  
  314.       Integer literals consist of a sequence of digits optionally  beginning
  315.       with  a  '+'  or '-'.  The range of values an integer can represent is
  316.       limited by the size of a C 'long' on the machine  on  which  XLISP  is
  317.       running.
  318.  
  319.       Floating  point  literals  consist  of a sequence of digits optionally
  320.       beginning with a '+' or '-' and including an embedded  decimal  point.
  321.       The  range  of values a floating point number can represent is limited
  322.       by the size  of  a  C  'float'  ('double'  on  machines  with  32  bit
  323.       addresses) on the machine on which XLISP is running.
  324.  
  325.       Literal strings are  sequences  of  characters  surrounded  by  double
  326.       quotes.   Within  quoted  strings  the  '\' character is used to allow
  327.       non-printable characters to be included.  The codes recognized are:
  328.  
  329.               \\      means the character '\'
  330.               \n      means newline
  331.               \t      means tab
  332.               \r      means return
  333.               \e      means escape
  334.               \nnn    means the character whose octal code is nnn
  335.  
  336.       XLISP defines several useful read macros:
  337.  
  338.               '<expr>  == (quote <expr>)
  339.               #'<expr> == (function <expr>)
  340.               `<expr>  == (backquote <expr>)
  341.               ,<expr>  == (comma <expr>)
  342.               ,@<expr> == (comma-at <expr>)
  343.  
  344.  
  345.       XLISP: An Experimental Object Oriented Language                Page 10
  346.       OBJECTS
  347.  
  348.  
  349.       8  OBJECTS
  350.  
  351.       Definitions:
  352.  
  353.             o  selector - a symbol used to select an appropriate method
  354.  
  355.             o  message - a selector and a list of actual arguments
  356.  
  357.             o  method - the code that implements a message
  358.  
  359.       Since XLISP was created to provide a simple  basis  for  experimenting
  360.       with  object  oriented  programming,  one  of the primitive data types
  361.       included is  'object'.   In  XLISP,  an  object  consists  of  a  data
  362.       structure containing a pointer to the object's class as well as a list
  363.       containing the values of the object's instance variables.
  364.  
  365.       Officially, there is no way to see  inside  an  object  (look  at  the
  366.       values  of  its instance variables).  The only way to communicate with
  367.       an object is by sending  it  a  message.   When  the  XLISP  evaluator
  368.       evaluates  a  list  the  value of whose first element is an object, it
  369.       interprets the value of the second element of the list (which must  be
  370.       a symbol) as the message selector.  The evaluator determines the class
  371.       of the receiving object and attempts to find a method corresponding to
  372.       the  message  selector  in the set of messages defined for that class.
  373.       If the message is not found in the object's class and the class has  a
  374.       super-class,  the  search continues by looking at the messages defined
  375.       for the super-class.  This process continues from one  super-class  to
  376.       the  next  until  a  method for the message is found.  If no method is
  377.       found, an error occurs.
  378.  
  379.       When a method is found, the evaluator binds the  receiving  object  to
  380.       the  symbol  'self',  binds the class in which the method was found to
  381.       the symbol 'msgclass', and evaluates the method  using  the  remaining
  382.       elements  of  the  original  list  as  arguments to the method.  These
  383.       arguments  are  always  evaluated  prior  to  being  bound  to   their
  384.       corresponding  formal  arguments.  The result of evaluating the method
  385.       becomes the result of the expression.
  386.  
  387.  
  388.       XLISP: An Experimental Object Oriented Language                Page 11
  389.       OBJECTS
  390.  
  391.  
  392.       8.1  THE 'Object' CLASS
  393.  
  394.       Classes:
  395.  
  396.       Object  THE TOP OF THE CLASS HEIRARCHY
  397.  
  398.           Messages:
  399.  
  400.               :show  SHOW AN OBJECT'S INSTANCE VARIABLES
  401.                   returns     the object
  402.  
  403.               :class  RETURN THE CLASS OF AN OBJECT
  404.                   returns     the class of the object
  405.  
  406.               :isnew  THE DEFAULT OBJECT INITIALIZATION ROUTINE
  407.                   returns     the object
  408.  
  409.               :sendsuper <sel> [<args>]...  SEND SUPERCLASS A MESSAGE
  410.                   <sel>       the message selector
  411.                   <args>      the message arguments
  412.                   returns     the result of sending the message
  413.  
  414.  
  415.       XLISP: An Experimental Object Oriented Language                Page 12
  416.       OBJECTS
  417.  
  418.  
  419.       8.2  THE 'Class' CLASS
  420.  
  421.       Class   THE CLASS OF ALL OBJECT CLASSES (including itself)
  422.  
  423.           Messages:
  424.  
  425.               :new  CREATE A NEW INSTANCE OF A CLASS
  426.                   returns     the new class object
  427.  
  428.               :isnew <ivars> [<cvars>[<super>]]  INITIALIZE A NEW CLASS
  429.                   <ivars>     the list of instance variables
  430.                   <cvars>     the list of class variables (default is nil)
  431.                   <super>     the superclass (default is Object)
  432.                   returns     the new class object
  433.  
  434.               :answer <msg> <fargs> <code>  ADD A MESSAGE TO A CLASS
  435.                   <msg>       the message symbol
  436.                   <fargs>     the formal argument list
  437.                                 this list is of the form:
  438.                                   ([<farg>]...
  439.                                    [&optional [<oarg>]...]
  440.                                    [&rest <rarg>]
  441.                                    [&aux [<aux>]...])
  442.                                 where
  443.                                   <farg>   a formal argument
  444.                                   <oarg>   an optional argument (default is nil)
  445.                                   <rarg>   bound to the rest of the arguments
  446.                                   <aux>    a auxiliary variable (set to nil)
  447.                   <code>      a list of executable expressions
  448.                   returns     the object
  449.  
  450.  
  451.       When  a  new  instance  of  a  class is created by sending the message
  452.       ':new' to an existing class, the message ':isnew' followed by whatever
  453.       parameters were passed to the ':new' message  is  sent  to  the  newly
  454.       created object.
  455.  
  456.       When  a  new  class  is  created  by sending the ':new' message to the
  457.       object 'Class', an optional parameter may be specified indicating  the
  458.       superclass of the new class.  If this parameter is  omitted,  the  new
  459.       class  will  be a subclass of 'Object'.  A class inherits all instance
  460.       variables, class variables, and methods from its super-class.
  461.  
  462.  
  463.       XLISP: An Experimental Object Oriented Language                Page 13
  464.       SYMBOLS
  465.  
  466.  
  467.       9  SYMBOLS
  468.  
  469.  
  470.             o  self - the current object (within a message context)
  471.  
  472.             o  msgclass - the class in which the current method was found
  473.  
  474.             o  *oblist* - the object list
  475.  
  476.             o  *keylist* - the keyword list
  477.  
  478.             o  *standard-input* - the standard input file
  479.  
  480.             o  *standard-output* - the standard output file
  481.  
  482.             o  *breakenable* - flag controlling entering the break  loop  on
  483.                errors
  484.  
  485.             o  *tracenable* - flag controlling trace back printout on errors
  486.                and breaks
  487.  
  488.             o  *tracelimit*  -  maximum  number  of  levels  of  trace  back
  489.                information printed on errors and breaks
  490.  
  491.             o  *evalhook* - user substitute for the evaluator function
  492.  
  493.             o  *applyhook* - (not yet implemented)
  494.  
  495.             o  *unbound* - indicator for unbound symbols
  496.  
  497.  
  498.  
  499.       XLISP: An Experimental Object Oriented Language                Page 14
  500.       FUNCTION DEFINITIONS
  501.  
  502.  
  503.       10  FUNCTION DEFINITIONS
  504.  
  505.       10.1  EVALUATION FUNCTIONS
  506.  
  507.       (eval <expr>)  EVALUATE AN XLISP EXPRESSION
  508.           <expr>      the expression to be evaluated
  509.           returns     the result of evaluating the expression
  510.  
  511.       (apply <fun> <args>)  APPLY A FUNCTION TO A LIST OF ARGUMENTS
  512.           <fun>       the function to apply (or function symbol)
  513.           <args>      the argument list
  514.           returns     the result of applying the function to the argument list
  515.  
  516.       (funcall <fun> [<arg>]...)  CALL A FUNCTION WITH ARGUMENTS
  517.           <fun>       the function to call (or function symbol)
  518.           <arg>       arguments to pass to the function
  519.           returns     the result of calling the function with the arguments
  520.  
  521.       (quote <expr>)  RETURN AN EXPRESSION UNEVALUATED
  522.           <expr>      the expression to be quoted (quoted)
  523.           returns     <expr> unevaluated
  524.  
  525.       (function <expr>)  QUOTE A FUNCTION
  526.           <expr>      the function to be quoted (quoted)
  527.           returns     a function closure
  528.  
  529.       (backquote <expr>)  FILL IN A TEMPLATE
  530.           <expr>      the template
  531.           returns     a copy of the template with comma and comma-at expressions
  532.                       expanded (see the Common Lisp reference manual)
  533.  
  534.  
  535.       XLISP: An Experimental Object Oriented Language                Page 15
  536.       SYMBOL FUNCTIONS
  537.  
  538.  
  539.       10.2  SYMBOL FUNCTIONS
  540.  
  541.       (set <sym> <expr>)  SET THE VALUE OF A SYMBOL
  542.           <sym>       the symbol being set
  543.           <expr>      the new value
  544.           returns     the new value
  545.  
  546.       (setq [<sym> <expr>]...)  SET THE VALUE OF A SYMBOL
  547.           <sym>       the symbol being set (quoted)
  548.           <expr>      the new value
  549.           returns     the new value
  550.  
  551.       (setf [<place> <expr>]...)  SET THE VALUE OF A FIELD
  552.           <place>     the field specifier (quoted):
  553.                           <sym>                set the value of a symbol
  554.                           (car <expr>)         set the car of a list node
  555.                           (cdr <expr>)         set the cdr of a list node
  556.                           (get <sym> <prop>)   set the value of a property
  557.                           (symbol-value <sym>) set the value of a symbol
  558.                           (symbol-plist <sym>) set the property list of a symbol
  559.           <value>     the new value
  560.           returns     the new value
  561.  
  562.       (defun <sym> <fargs> [<expr>]...)  DEFINE A FUNCTION
  563.       (defmacro <sym> <fargs> [<expr>]...)  DEFINE A MACRO
  564.           <sym>       symbol being defined (quoted)
  565.           <fargs>     list of formal arguments (quoted)
  566.                         this list is of the form:
  567.                           ([<farg>]...
  568.                            [&optional [<oarg>]...]
  569.                            [&rest <rarg>]
  570.                            [&aux [<aux>]...])
  571.                         where
  572.                           <farg>      is a formal argument
  573.                           <oarg>      is an optional argument (default is nil)
  574.                           <rarg>      bound to the rest of the arguments
  575.                           <aux>       is an auxiliary variable (set to nil)
  576.           <expr>      expressions constituting the body of the
  577.                       function (quoted)
  578.           returns     the function symbol
  579.  
  580.       (gensym [<tag>])  GENERATE A SYMBOL
  581.           <tag>       string or number
  582.           returns     the new symbol
  583.  
  584.       (intern <pname>)  MAKE AN INTERNED SYMBOL
  585.           <pname>     the symbol's print name string
  586.           returns     the new symbol
  587.  
  588.       (make-symbol <pname>)  MAKE AN UNINTERNED SYMBOL
  589.           <pname>     the symbol's print name string
  590.           returns     the new symbol
  591.  
  592.  
  593.       XLISP: An Experimental Object Oriented Language                Page 16
  594.       SYMBOL FUNCTIONS
  595.  
  596.  
  597.       (symbol-name <sym>)  GET THE PRINT NAME OF A SYMBOL
  598.           <sym>       the symbol
  599.           returns     the symbol's print name
  600.  
  601.       (symbol-value <sym>)  GET THE VALUE OF A SYMBOL
  602.           <sym>       the symbol
  603.           returns     the symbol's value
  604.  
  605.       (symbol-plist <sym>)  GET THE PROPERTY LIST OF A SYMBOL
  606.           <sym>       the symbol
  607.           returns     the symbol's property list
  608.  
  609.  
  610.       XLISP: An Experimental Object Oriented Language                Page 17
  611.       PROPERTY LIST FUNCTIONS
  612.  
  613.  
  614.       10.3  PROPERTY LIST FUNCTIONS
  615.  
  616.       (get <sym> <prop>)  GET THE VALUE OF A PROPERTY
  617.           <sym>       the symbol
  618.           <prop>      the property symbol
  619.           returns     the property value or nil
  620.  
  621.       (putprop <sym> <val> <prop>)  PUT A PROPERTY ONTO THE PROPERTY LIST
  622.           <sym>       the symbol
  623.           <val>       the property value
  624.           <prop>      the property symbol
  625.           returns     nil
  626.  
  627.       (remprop <sym> <prop>)  REMOVE A PROPERTY
  628.           <sym>       the symbol
  629.           <prop>      the property symbol
  630.  
  631.  
  632.       XLISP: An Experimental Object Oriented Language                Page 18
  633.       LIST FUNCTIONS
  634.  
  635.  
  636.       10.4  LIST FUNCTIONS
  637.  
  638.       (car <expr>)  RETURN THE CAR OF A LIST NODE
  639.           <expr>      the list node
  640.           returns     the car of the list node
  641.  
  642.       (cdr <expr>)  RETURN THE CDR OF A LIST NODE
  643.           <expr>      the list node
  644.           returns     the cdr of the list node
  645.  
  646.       (caar <expr>) == (car (car <expr>))
  647.       (cadr <expr>) == (car (cdr <expr>))
  648.       (cdar <expr>) == (cdr (car <expr>))
  649.       (cddr <expr>) == (cdr (cdr <expr>))
  650.  
  651.       (cons <expr1> <expr2>)  CONSTRUCT A NEW LIST NODE
  652.           <expr1>     the car of the new list node
  653.           <expr2>     the cdr of the new list node
  654.           returns     the new list node
  655.  
  656.       (list [<expr>]...)  CREATE A LIST OF VALUES
  657.           <expr>      expressions to be combined into a list
  658.           returns     the new list
  659.  
  660.       (append [<expr>]...)  APPEND LISTS
  661.           <expr>      lists whose elements are to be appended
  662.           returns     the new list
  663.  
  664.       (reverse <expr>)  REVERSE A LIST
  665.           <expr>      the list to reverse
  666.           returns     a new list in the reverse order
  667.  
  668.       (last <list>)  RETURN THE LAST LIST NODE OF A LIST
  669.           <list>      the list
  670.           returns     the last list node in the list
  671.  
  672.       (member <expr> <list> [<key> <test>])  FIND AN EXPRESSION IN A LIST
  673.           <expr>      the expression to find
  674.           <list>      the list to search
  675.           <key>       the keyword :test or :test-not
  676.           <test>      the test function (defaults to eql)
  677.           returns     the remainder of the list starting with the expression
  678.  
  679.       (assoc <expr> <alist> [<key> <test>])  FIND AN EXPRESSION IN AN A-LIST
  680.           <expr>      the expression to find
  681.           <alist>     the association list
  682.           <key>       the keyword :test or :test-not
  683.           <test>      the test function (defaults to eql)
  684.           returns     the alist entry or nil
  685.  
  686.  
  687.       XLISP: An Experimental Object Oriented Language                Page 19
  688.       LIST FUNCTIONS
  689.  
  690.  
  691.       (remove <expr> <list> [<key> <test>])  REMOVE AN EXPRESSION FROM A LIST
  692.           <expr>      the expression to delete
  693.           <list>      the list
  694.           <key>       the keyword :test or :test-not
  695.           <test>      the test function (defaults to eql)
  696.           returns     the list with the matching expressions deleted
  697.  
  698.       (length <expr>)  FIND THE LENGTH OF A LIST OR STRING
  699.           <expr>      the list or string
  700.           returns     the length of the list or string
  701.  
  702.       (nth <n> <list>)  RETURN THE NTH ELEMENT OF A LIST
  703.           <n>         the number of the element to return (zero origin)
  704.           <list>      the list
  705.           returns     the nth element or nil if the list isn't that long
  706.  
  707.       (nthcdr <n> <list>)  RETURN THE NTH CDR OF A LIST
  708.           <n>         the number of the element to return (zero origin)
  709.           <list>      the list
  710.           returns     the nth cdr or nil if the list isn't that long
  711.  
  712.       (mapc <fcn> <list1> [<list>]...)  APPLY FUNCTION TO SUCCESSIVE CARS
  713.           <fcn>       the function or function name
  714.           <listn>     a list for each argument of the function
  715.           returns     the first list of arguments
  716.  
  717.       (mapcar <fcn> <list1> [<list>]...)  APPLY FUNCTION TO SUCCESSIVE CARS
  718.           <fcn>       the function or function name
  719.           <listn>     a list for each argument of the function
  720.           returns     the list of values returned by each function invocation
  721.  
  722.       (mapl <fcn> <list1> [<list>]...)  APPLY FUNCTION TO SUCCESSIVE CDRS
  723.           <fcn>       the function or function name
  724.           <listn>     a list for each argument of the function
  725.           returns     the first list of arguments
  726.  
  727.       (maplist <fcn> <list1> [<list>]...)  APPLY FUNCTION TO SUCCESSIVE CDRS
  728.           <fcn>       the function or function name
  729.           <listn>     a list for each argument of the function
  730.           returns     the list of values returned by each function invocation
  731.  
  732.  
  733.       XLISP: An Experimental Object Oriented Language                Page 20
  734.       LIST FUNCTIONS
  735.  
  736.  
  737.       (subst <to> <from> <expr> [<key> <test>])  SUBSTITUTE EXPRESSIONS
  738.           <to>        the new expression
  739.           <from>      the old expression
  740.           <expr>      the expression in which to do the substitutions
  741.           <key>       the keyword :test or :test-not
  742.           <test>      the test function (defaults to eql)
  743.           returns     the expression with substitutions
  744.  
  745.       (sublis <alist> <expr> [<key> <test>])  SUBSTITUTE USING AN A-LIST
  746.           <alist>     the association list
  747.           <expr>      the expression in which to do the substitutions
  748.           <key>       the keyword :test or :test-not
  749.           <test>      the test function (defaults to eql)
  750.           returns     the expression with substitutions
  751.  
  752.  
  753.       XLISP: An Experimental Object Oriented Language                Page 21
  754.       DESTRUCTIVE LIST FUNCTIONS
  755.  
  756.  
  757.       10.5  DESTRUCTIVE LIST FUNCTIONS
  758.  
  759.       (rplaca <list> <expr>)  REPLACE THE CAR OF A LIST NODE
  760.           <list>      the list node
  761.           <expr>      the new value for the car of the list node
  762.           returns     the list node after updating the car
  763.  
  764.       (rplacd <list> <expr>)  REPLACE THE CDR OF A LIST NODE
  765.           <list>      the list node
  766.           <expr>      the new value for the cdr of the list node
  767.           returns     the list node after updating the cdr
  768.  
  769.       (nconc [<list>]...)  DESTRUCTIVELY CONCATENATE LISTS
  770.           <list>      lists to concatenate
  771.           returns     the result of concatenating the lists
  772.  
  773.       (delete <expr> <list> [<key> <test>])  DELETE AN EXPRESSION FROM A LIST
  774.           <expr>      the expression to delete
  775.           <list>      the list
  776.           <key>       the keyword :test or :test-not
  777.           <test>      the test function (defaults to eql)
  778.           returns     the list with the matching expressions deleted
  779.  
  780.  
  781.       XLISP: An Experimental Object Oriented Language                Page 22
  782.       PREDICATE FUNCTIONS
  783.  
  784.  
  785.       10.6  PREDICATE FUNCTIONS
  786.  
  787.       (atom <expr>)  IS THIS AN ATOM?
  788.           <expr>      the expression to check
  789.           returns     t if the value is an atom, nil otherwise
  790.  
  791.       (symbolp <expr>)  IS THIS A SYMBOL?
  792.           <expr>      the expression to check
  793.           returns     t if the expression is a symbol, nil otherwise
  794.  
  795.       (numberp <expr>)  IS THIS A NUMBER?
  796.           <expr>      the expression to check
  797.           returns     t if the expression is a number, nil otherwise
  798.  
  799.       (null <expr>)  IS THIS AN EMPTY LIST?
  800.           <expr>      the list to check
  801.           returns     t if the list is empty, nil otherwise
  802.  
  803.       (not <expr>)  IS THIS FALSE?
  804.           <expr>      the expression to check
  805.           return      t if the expression is nil, nil otherwise
  806.  
  807.       (listp <expr>)  IS THIS A LIST?
  808.           <expr>      the expression to check
  809.           returns     t if the value is a list node or nil, nil otherwise
  810.  
  811.       (consp <expr>)  IS THIS A NON-EMPTY LIST?
  812.           <expr>      the expression to check
  813.           returns     t if the value is a list node, nil otherwise
  814.  
  815.       (boundp <sym>)  IS THIS A BOUND SYMBOL?
  816.           <sym>       the symbol
  817.           returns     t if a value is bound to the symbol, nil otherwise
  818.  
  819.  
  820.       XLISP: An Experimental Object Oriented Language                Page 23
  821.       PREDICATE FUNCTIONS
  822.  
  823.  
  824.       (minusp <expr>)  IS THIS NUMBER NEGATIVE?
  825.           <expr>      the number to test
  826.           returns     t if the number is negative, nil otherwise
  827.  
  828.       (zerop <expr>)  IS THIS NUMBER ZERO?
  829.           <expr>      the number to test
  830.           returns     t if the number is zero, nil otherwise
  831.  
  832.       (plusp <expr>)  IS THIS NUMBER POSITIVE?
  833.           <expr>      the number to test
  834.           returns     t if the number is positive, nil otherwise
  835.  
  836.       (evenp <expr>)  IS THIS NUMBER EVEN?
  837.           <expr>      the number to test
  838.           returns     t if the number is even, nil otherwise
  839.  
  840.       (oddp <expr>)  IS THIS NUMBER ODD?
  841.           <expr>      the number to test
  842.           returns     t if the number is odd, nil otherwise
  843.  
  844.       (eq <expr1> <expr2>)  ARE THE EXPRESSIONS IDENTICAL?
  845.           <expr1>     the first expression
  846.           <expr2>     the second expression
  847.           returns     t if they are equal, nil otherwise
  848.  
  849.       (eql <expr1> <expr2>)  ARE THE EXPRESSIONS IDENTICAL?
  850.                               (WORKS WITH NUMBERS AND STRINGS)
  851.           <expr1>     the first expression
  852.           <expr2>     the second expression
  853.           returns     t if they are equal, nil otherwise
  854.  
  855.       (equal <expr1> <expr2>)  ARE THE EXPRESSIONS EQUAL?
  856.           <expr1>     the first expression
  857.           <expr2>     the second expression
  858.           returns     t if they are equal, nil otherwise
  859.  
  860.  
  861.       XLISP: An Experimental Object Oriented Language                Page 24
  862.       CONTROL FUNCTIONS
  863.  
  864.  
  865.       10.7  CONTROL FUNCTIONS
  866.  
  867.       (cond [<pair>]...)  EVALUATE CONDITIONALLY
  868.           <pair>      pair consisting of:
  869.                           (<pred> [<expr>]...)
  870.                         where
  871.                           <pred>      is a predicate expression
  872.                           <expr>      evaluated if the predicate
  873.                                       is not nil
  874.           returns     the value of the first expression whose predicate
  875.                       is not nil
  876.  
  877.       (and [<expr>]...)  THE LOGICAL AND OF A LIST OF EXPRESSIONS
  878.           <expr>      the expressions to be ANDed
  879.           returns     nil if any expression evaluates to nil,
  880.                       otherwise the value of the last expression
  881.                       (evaluation of expressions stops after the first
  882.                        expression that evaluates to nil)
  883.  
  884.       (or [<expr>]...)  THE LOGICAL OR OF A LIST OF EXPRESSIONS
  885.           <expr>      the expressions to be ORed
  886.           returns     nil if all expressions evaluate to nil,
  887.                       otherwise the value of the first non-nil expression
  888.                       (evaluation of expressions stops after the first
  889.                        expression that does not evaluate to nil)
  890.  
  891.       (if <texpr> <expr1> [<expr2>])  EXECUTE EXPRESSIONS CONDITIONALLY
  892.           <texpr>     the test expression
  893.           <expr1>     the expression to be evaluated if texpr is non-nil
  894.           <expr2>     the expression to be evaluated if texpr is nil
  895.           returns     the value of the selected expression
  896.  
  897.       (let ([<binding>]...) [<expr>]...)  BIND SYMBOLS AND EVALUATE EXPRESSIONS
  898.       (let* ([<binding>]...) [<expr>]...)  LET WITH SEQUENTIAL BINDING
  899.           <binding>   the variable bindings each of which is either:
  900.                       1)  a symbol (which is initialized to nil)
  901.                       2)  a list whose car is a symbol and whose cadr
  902.                               is an initialization expression
  903.           <expr>      the expressions to be evaluated
  904.           returns     the value of the last expression
  905.  
  906.       (catch <sym> [<expr>]...)  EVALUATE EXPRESSIONS AND CATCH THROWS
  907.           <sym>       the catch tag
  908.           <expr>      expressions to evaluate
  909.           returns     the value of the last expression the throw expression
  910.  
  911.       (throw <sym> [<expr>])  THROW TO A CATCH
  912.           <sym>       the catch tag
  913.           <expr>      the value for the catch to return (defaults to nil)
  914.           returns     never returns
  915.  
  916.  
  917.       XLISP: An Experimental Object Oriented Language                Page 25
  918.       LOOPING FUNCTIONS
  919.  
  920.  
  921.       10.8  LOOPING FUNCTIONS
  922.  
  923.       (do ([<binding>]...) (<texpr> [<rexpr>]...) [<expr>]...)
  924.       (do* ([<binding>]...) (<texpr> [<rexpr>]...) [<expr>]...)
  925.           <binding>   the variable bindings each of which is either:
  926.                       1)  a symbol (which is initialized to nil)
  927.                       2)  a list of the form: (<sym> <init> [<step>])
  928.                           where:
  929.                               <sym>  is the symbol to bind
  930.                               <init> is the initial value of the symbol
  931.                               <step> is a step expression
  932.           <texpr>     the termination test expression
  933.           <rexpr>     result expressions (the default is nil)
  934.           <expr>      the body of the loop (treated like an implicit prog)
  935.           returns     the value of the last result expression
  936.  
  937.       (dolist (<sym> <expr> [<rexpr>]) [<expr>]...)  LOOP THROUGH A LIST
  938.           <sym>       the symbol to bind to each list element
  939.           <expr>      the list expression
  940.           <rexpr>     the result expression (the default is nil)
  941.           <expr>      the body of the loop (treated like an implicit prog)
  942.  
  943.       (dotimes (<sym> <expr> [<rexpr>]) [<expr>]...)  LOOP FROM ZERO TO N-1
  944.           <sym>       the symbol to bind to each value from 0 to n-1
  945.           <expr>      the number of times to loop
  946.           <rexpr>     the result expression (the default is nil)
  947.           <expr>      the body of the loop (treated like an implicit prog)
  948.  
  949.  
  950.       XLISP: An Experimental Object Oriented Language                Page 26
  951.       THE PROGRAM FEATURE
  952.  
  953.  
  954.       10.9  THE PROGRAM FEATURE
  955.  
  956.       (prog ([<binding>]...) [<expr>]...)  THE PROGRAM FEATURE
  957.       (prog* ([<binding>]...) [<expr>]...)  PROG WITH SEQUENTIAL BINDING
  958.           <binding>   the variable bindings each of which is either:
  959.                       1)  a symbol (which is initialized to nil)
  960.                       2)  a list whose car is a symbol and whose cadr
  961.                               is an initialization expression
  962.           <expr>      expressions to evaluate or tags (symbols)
  963.           returns     nil or the argument passed to the return function
  964.  
  965.       (go <sym>)  GO TO A TAG WITHIN A PROG CONSTRUCT
  966.           <sym>       the tag (quoted)
  967.           returns     never returns
  968.  
  969.       (return [<expr>])  CAUSE A PROG CONSTRUCT TO RETURN A VALUE
  970.           <expr>      the value (defaults to nil)
  971.           returns     never returns
  972.  
  973.       (prog1 <expr1> [<expr>]...)  EXECUTE EXPRESSIONS SEQUENTIALLY
  974.           <expr1>     the first expression to evaluate
  975.           <expr>      the remaining expressions to evaluate
  976.           returns     the value of the first expression
  977.  
  978.       (prog2 <expr1> <expr2> [<expr>]...)  EXECUTE EXPRESSIONS SEQUENTIALLY
  979.           <expr1>     the first expression to evaluate
  980.           <expr2>     the second expression to evaluate
  981.           <expr>      the remaining expressions to evaluate
  982.           returns     the value of the second expression
  983.  
  984.       (progn [<expr>]...)  EXECUTE EXPRESSIONS SEQUENTIALLY
  985.           <expr>      the expressions to evaluate
  986.           returns     the value of the last expression (or nil)
  987.  
  988.  
  989.       XLISP: An Experimental Object Oriented Language                Page 27
  990.       DEBUGGING AND ERROR HANDLING
  991.  
  992.  
  993.       10.10  DEBUGGING AND ERROR HANDLING
  994.  
  995.       (error <emsg> [<arg>])  SIGNAL A NON-CORRECTABLE ERROR
  996.           <emsg>      the error message string
  997.           <arg>       the argument expression (printed after the message)
  998.           returns     never returns
  999.  
  1000.       (cerror <cmsg> <emsg> [<arg>])  SIGNAL A CORRECTABLE ERROR
  1001.           <cmsg>      the continue message string
  1002.           <emsg>      the error message string
  1003.           <arg>       the argument expression (printed after the message)
  1004.           returns     nil when continued from the break loop
  1005.  
  1006.       (break [<bmsg> [<arg>]])  ENTER A BREAK LOOP
  1007.           <bmsg>      the break message string (defaults to "**BREAK**")
  1008.           <arg>       the argument expression (printed after the message)
  1009.           returns     nil when continued from the break loop
  1010.  
  1011.       (clean-up)  CLEAN-UP AFTER AN ERROR
  1012.           returns     never returns
  1013.  
  1014.       (continue)  CONTINUE FROM A CORRECTABLE ERROR
  1015.           returns     never returns
  1016.  
  1017.       (errset <expr> [<pflag>])  TRAP ERRORS
  1018.           <expr>      the expression to execute
  1019.           <pflag>     flag to control printing of the error message
  1020.           returns     the value of the last expression consed with nil
  1021.                       or nil on error
  1022.  
  1023.       (baktrace [<n>])  PRINT N LEVELS OF TRACE BACK INFORMATION
  1024.           <n>         the number of levels (defaults to all levels)
  1025.           returns     nil
  1026.  
  1027.       (evalhook <expr> <ehook> <ahook>)  EVALUATE AN EXPRESSION WITH HOOKS
  1028.           <expr>      the expression to evaluate
  1029.           <ehook>     the value for *evalhook*
  1030.           <ahook>     the value for *applyhook*
  1031.           returns     the result of evaluating the expression
  1032.  
  1033.  
  1034.       XLISP: An Experimental Object Oriented Language                Page 28
  1035.       ARITHMETIC FUNCTIONS
  1036.  
  1037.  
  1038.       10.11  ARITHMETIC FUNCTIONS
  1039.  
  1040.       (truncate <expr>)  TRUNCATES A FLOATING POINT NUMBER TO AN INTEGER
  1041.           <expr>      the number
  1042.           returns     the result of truncating the number
  1043.  
  1044.       (float <expr>)  CONVERTS AN INTEGER TO A FLOATING POINT NUMBER
  1045.           <expr>      the number
  1046.           returns     the result of floating the integer
  1047.  
  1048.       (+ <expr>...)  ADD A LIST OF NUMBERS
  1049.           <expr>      the numbers
  1050.           returns     the result of the addition
  1051.  
  1052.       (- <expr>...)  SUBTRACT A LIST OF NUMBERS OR NEGATE A SINGLE NUMBER
  1053.           <expr>      the numbers
  1054.           returns     the result of the subtraction
  1055.  
  1056.       (* <expr>...)  MULTIPLY A LIST OF NUMBERS
  1057.           <expr>      the numbers
  1058.           returns     the result of the multiplication
  1059.  
  1060.       (/ <expr>...)  DIVIDE A LIST OF NUMBERS
  1061.           <expr>      the numbers
  1062.           returns     the result of the division
  1063.  
  1064.       (1+ <expr>)  ADD ONE TO A NUMBER
  1065.           <expr>      the number
  1066.           returns     the number plus one
  1067.  
  1068.       (1- <expr>)  SUBTRACT ONE FROM A NUMBER
  1069.           <expr>      the number
  1070.           returns     the number minus one
  1071.  
  1072.       (rem <expr>...)  REMAINDER OF A LIST OF NUMBERS
  1073.           <expr>      the numbers
  1074.           returns     the result of the remainder operation
  1075.  
  1076.       (min <expr>...)  THE SMALLEST OF A LIST OF NUMBERS
  1077.           <expr>      the expressions to be checked
  1078.           returns     the smallest number in the list
  1079.  
  1080.       (max <expr>...)  THE LARGEST OF A LIST OF NUMBERS
  1081.           <expr>      the expressions to be checked
  1082.           returns     the largest number in the list
  1083.  
  1084.       (abs <expr>)  THE ABSOLUTE VALUE OF A NUMBER
  1085.           <expr>      the number
  1086.           returns     the absolute value of the number
  1087.  
  1088.  
  1089.       XLISP: An Experimental Object Oriented Language                Page 29
  1090.       ARITHMETIC FUNCTIONS
  1091.  
  1092.  
  1093.       (sin <expr>)  COMPUTE THE SINE OF A NUMBER
  1094.           <expr>      the floating point number
  1095.           returns     the sine of the number
  1096.  
  1097.       (cos <expr>)  COMPUTE THE COSINE OF A NUMBER
  1098.           <expr>      the floating point number
  1099.           returns     the cosine of the number
  1100.  
  1101.       (tan <expr>)  COMPUTE THE TANGENT OF A NUMBER
  1102.           <expr>      the floating point number
  1103.           returns     the tangent of the number
  1104.  
  1105.       (expt <x-expr> <y-expr>)  COMPUTE X TO THE Y POWER
  1106.           <x-expr>    the floating point number
  1107.           <y-expr>    the floating point exponent
  1108.           returns     x to the y power
  1109.  
  1110.       (exp <x-expr>)  COMPUTE E TO THE X POWER
  1111.           <x-expr>    the floating point number
  1112.           returns     e to the x power
  1113.  
  1114.       (sqrt <expr>)  COMPUTE THE SQUARE ROOT OF A NUMBER
  1115.           <expr>      the floating point number
  1116.           returns     the square root of the number
  1117.  
  1118.  
  1119.       XLISP: An Experimental Object Oriented Language                Page 30
  1120.       BITWISE LOGICAL FUNCTIONS
  1121.  
  1122.  
  1123.       10.12  BITWISE LOGICAL FUNCTIONS
  1124.  
  1125.       (bit-and <expr>...)  THE BITWISE AND OF A LIST OF NUMBERS
  1126.           <expr>      the numbers
  1127.           returns     the result of the and operation
  1128.  
  1129.       (bit-ior <expr>...)  THE BITWISE INCLUSIVE OR OF A LIST OF NUMBERS
  1130.           <expr>      the numbers
  1131.           returns     the result of the inclusive or operation
  1132.  
  1133.       (bit-xor <expr>...)  THE BITWISE EXCLUSIVE OR OF A LIST OF NUMBERS
  1134.           <expr>      the numbers
  1135.           returns     the result of the exclusive or operation
  1136.  
  1137.       (bit-not <expr>)  THE BITWISE NOT OF A NUMBER
  1138.           <expr>      the number
  1139.           returns     the bitwise inversion of number
  1140.  
  1141.  
  1142.       XLISP: An Experimental Object Oriented Language                Page 31
  1143.       RELATIONAL FUNCTIONS
  1144.  
  1145.  
  1146.       10.13  RELATIONAL FUNCTIONS
  1147.  
  1148.       The relational functions can be used  to  compare  integers,  floating
  1149.       point numbers or strings.
  1150.  
  1151.       (< <e1> <e2>)  TEST FOR LESS THAN
  1152.           <e1>        the left operand of the comparison
  1153.           <e2>        the right operand of the comparison
  1154.           returns     the result of comparing <e1> with <e2>
  1155.  
  1156.       (<= <e1> <e2>)  TEST FOR LESS THAN OR EQUAL TO
  1157.           <e1>        the left operand of the comparison
  1158.           <e2>        the right operand of the comparison
  1159.           returns     the result of comparing <e1> with <e2>
  1160.  
  1161.       (= <e1> <e2>)  TEST FOR EQUAL TO
  1162.           <e1>        the left operand of the comparison
  1163.           <e2>        the right operand of the comparison
  1164.           returns     the result of comparing <e1> with <e2>
  1165.  
  1166.       (/= <e1> <e2>)  TEST FOR NOT EQUAL TO
  1167.           <e1>        the left operand of the comparison
  1168.           <e2>        the right operand of the comparison
  1169.           returns     the result of comparing <e1> with <e2>
  1170.  
  1171.       (>= <e1> <e2>)  TEST FOR GREATER THAN OR EQUAL TO
  1172.           <e1>        the left operand of the comparison
  1173.           <e2>        the right operand of the comparison
  1174.           returns     the result of comparing <e1> with <e2>
  1175.  
  1176.       (> <e1> <e2>)  TEST FOR GREATER THAN
  1177.           <e1>        the left operand of the comparison
  1178.           <e2>        the right operand of the comparison
  1179.           returns     the result of comparing <e1> with <e2>
  1180.  
  1181.  
  1182.       XLISP: An Experimental Object Oriented Language                Page 32
  1183.       STRING FUNCTIONS
  1184.  
  1185.  
  1186.       10.14  STRING FUNCTIONS
  1187.  
  1188.       (char <string> <index>)  EXTRACT A CHARACTER FROM A STRING
  1189.           <string>    the string
  1190.           <index>     the string index (zero relative)
  1191.           returns     the ascii code of the first character
  1192.  
  1193.       (string <expr>)  MAKE A STRING FROM AN INTEGER ASCII VALUE
  1194.           <expr>      the numeric expression
  1195.           returns     a one character string whose first character is <expr>
  1196.  
  1197.       (strcat [<expr>]...)  CONCATENATE STRINGS
  1198.           <expr>      the strings to concatenate
  1199.           returns     the result of concatenating the strings
  1200.  
  1201.       (substr <expr> <sexpr> [<lexpr>]) EXTRACT A SUBSTRING
  1202.           <expr>      the string
  1203.           <sexpr>     the starting position
  1204.           <lexpr>     the length (default is rest of string)
  1205.           returns     substring starting at <sexpr> for <lexpr>
  1206.  
  1207.  
  1208.       XLISP: An Experimental Object Oriented Language                Page 33
  1209.       INPUT/OUTPUT FUNCTIONS
  1210.  
  1211.  
  1212.       10.15  INPUT/OUTPUT FUNCTIONS
  1213.  
  1214.       (read [<source> [<eof>]])  READ AN XLISP EXPRESSION
  1215.           <source>    the input source (default is standard input)
  1216.           <eof>       the value to return on end of file (default is nil)
  1217.           returns     the expression read
  1218.  
  1219.       (print <expr> [<sink>])  PRINT A LIST OF VALUES ON A NEW LINE
  1220.           <expr>      the expressions to be printed
  1221.           <sink>      the output sink (default is standard output)
  1222.           returns     the expression
  1223.  
  1224.       (prin1 <expr> [<sink>])  PRINT A LIST OF VALUES
  1225.           <expr>      the expressions to be printed
  1226.           <sink>      the output sink (default is standard output)
  1227.           returns     the expression
  1228.  
  1229.       (princ <expr> [<sink>])  PRINT A LIST OF VALUES WITHOUT QUOTING
  1230.           <expr>      the expressions to be printed
  1231.           <sink>      the output sink (default is standard output)
  1232.           returns     the expression
  1233.  
  1234.       (terpri [<sink>])  TERMINATE THE CURRENT PRINT LINE
  1235.           <sink>      the output sink (default is standard output)
  1236.           returns     nil
  1237.  
  1238.       (flatsize <expr>)  LENGTH OF PRINTED REPRESENTATION USING PRIN1
  1239.           <expr>      the expression
  1240.           returns     the length
  1241.  
  1242.       (flatc <expr>)  LENGTH OF PRINTED REPRESENTATION USING PRINC
  1243.           <expr>      the expression
  1244.           returns     the length
  1245.  
  1246.  
  1247.  
  1248.       XLISP: An Experimental Object Oriented Language                Page 34
  1249.       FILE I/O FUNCTIONS
  1250.  
  1251.  
  1252.       10.16  FILE I/O FUNCTIONS
  1253.  
  1254.       (openi <fname>)  OPEN AN INPUT FILE
  1255.           <fname>     the file name string
  1256.           returns     a file pointer
  1257.  
  1258.       (openo <fname>)  OPEN AN OUTPUT FILE
  1259.           <fname>     the file name string
  1260.           returns     a file pointer
  1261.  
  1262.       (close <fp>)  CLOSE A FILE
  1263.           <fp>        the file pointer
  1264.           returns     nil
  1265.  
  1266.       (read-char [<source>])  READ A CHARACTER FROM A FILE OR STREAM
  1267.           <source>    the input source (default is standard input)
  1268.           returns     the character (integer)
  1269.  
  1270.       (peek-char [<flag> [<source>]])  PEEK AT THE NEXT CHARACTER
  1271.           <flag>      flag for skipping white space (default is nil)
  1272.           <source>    the input source (default is standard input)
  1273.           returns     the character (integer)
  1274.  
  1275.       (write-char <ch> [<sink>])  WRITE A CHARACTER TO A FILE OR STREAM
  1276.           <ch>        the character to put (integer)
  1277.           <sink>      the output sink (default is standard output)
  1278.           returns     the character (integer)
  1279.  
  1280.       (read-line [<source>])  READ A LINE FROM A FILE OR STREAM
  1281.           <source>    the input source (default is standard input)
  1282.           returns     the input string
  1283.  
  1284.  
  1285.       XLISP: An Experimental Object Oriented Language                Page 35
  1286.       SYSTEM FUNCTIONS
  1287.  
  1288.  
  1289.       10.17  SYSTEM FUNCTIONS
  1290.  
  1291.       (load <fname> [<vflag> [<pflag>]])  LOAD AN XLISP SOURCE FILE
  1292.           <fname>     the filename string (in double quotes)
  1293.           <vflag>     the verbose flag (default is t)
  1294.           <pflag>     the print flag (default is nil)
  1295.           returns     the filename
  1296.  
  1297.       (gc)  FORCE GARBAGE COLLECTION
  1298.           returns     nil
  1299.  
  1300.       (expand <num>)  EXPAND MEMORY BY ADDING SEGMENTS
  1301.           <num>       the number of segments to add
  1302.           returns     the number of segments added
  1303.  
  1304.       (alloc <num>)  CHANGE NUMBER OF NODES TO ALLOCATE IN EACH SEGMENT
  1305.           <num>       the number of nodes to allocate
  1306.           returns     the old number of nodes to allocate
  1307.  
  1308.       (mem)  SHOW MEMORY ALLOCATION STATISTICS
  1309.           returns     nil
  1310.  
  1311.       (type-of <expr>)  RETURNS THE TYPE OF THE EXPRESSION
  1312.           <expr>      the expression to return the type of
  1313.           returns     nil if the value is nil otherwise one of the symbols:
  1314.                           :SYMBOL   for symbols
  1315.                           :OBJECT   for objects
  1316.                           :CONS     for list nodes
  1317.                           :SUBR     for subroutines with evaluated arguments
  1318.                           :FSUBR    for subroutines with unevaluated arguments
  1319.                           :STRING   for string nodes
  1320.                           :FIXNUM   for integer nodes
  1321.                           :FLONUM   for floating point nodes
  1322.                           :FILE     for file pointer nodes
  1323.  
  1324.       (exit)  EXIT XLISP
  1325.           returns     never returns
  1326.